package com.leenmvc.core.security.entity.core;

import com.leenmvc.core.annotation.DbInfo;
import com.leenmvc.core.annotation.FillField;
import com.leenmvc.core.annotation.PrimaryKey;
import com.leenmvc.core.annotation.TableField;
import com.leenmvc.core.annotation.validator.Foreign;
import com.leenmvc.core.annotation.validator.Uniqueness;
import com.leenmvc.core.annotation.validator.groups.AddGroup;
import com.leenmvc.core.annotation.validator.groups.UpdateGroup;
import com.leenmvc.core.base.BaseEntity;
import com.leenmvc.core.enums.UniqueTypeEnum;
import com.leenmvc.core.security.dao.core.SysRoleDao;
import com.leenmvc.core.security.dao.core.SysUserDao;

import javax.validation.constraints.NotNull;
import java.util.Date;

/**
 * 角色用户关系
 *
 * @author leen
 * @since 1.0.0
 */
@DbInfo(value = "sys_role_user", comment = "用户角色")
public class SysRoleUser extends BaseEntity {

	@PrimaryKey(uniqueType = UniqueTypeEnum.SNOW)
    private Long id;
	/**
	 * 角色ID
	 */
	@Foreign(message = "该角色不存在或者已经被删除", value = SysRoleDao.class, groups = {AddGroup.class, UpdateGroup.class})
	@NotNull(message = "角色不能为空！", groups = {AddGroup.class, UpdateGroup.class})
	@Uniqueness(linkFields = "userId", groups = {AddGroup.class, UpdateGroup.class})
	private Long roleId;

	@TableField(false)
	@FillField(entity = SysRole.class, outField = "name", inField = "roleId")
	private String roleName;

	/**
	 * 用户ID
	 */
	@NotNull(message = "用户不能为空！", groups = {AddGroup.class, UpdateGroup.class})
	@Foreign(message = "该用户不存在或者已经被删除", value = SysUserDao.class, groups = {AddGroup.class, UpdateGroup.class})
	private Long userId;

	@TableField(false)
	@FillField(entity = SysUser.class, outField = "username", inField = "userId")
	private String username;

	@TableField(false)
	@FillField(entity = SysUser.class, outField = "realName", inField = "userId")
	private String realName;

	@TableField(false)
	@FillField(entity = SysUser.class, outField = "gender", inField = "userId")
	private Integer gender;

//	@TableField(false)
//	@FillField(entity = SysUser.class, type = 0, outField = "userType", inField = "userId")
//	private Integer userType;

	@TableField(false)
	@FillField(entity = SysUser.class, outField = "duties", inField = "userId")
	private String duties;

	@TableField(false)
	@FillField(entity = SysUser.class, outField = "customName", inField = "userId")
	private String customName;

	@TableField(false)
	@FillField(entity = SysRole.class, outField = "remark", inField = "roleId")
	private String remark;

	@TableField(false)
	@FillField(entity = SysUser.class, outField = "status", inField = "userId")
	private Integer status;

	protected Long creator;

	protected Date createDate;

	public Long getCreator() {
		return creator;
	}

	public void setCreator(Long creator) {
		this.creator = creator;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getRoleId() {
		return roleId;
	}

	public void setRoleId(Long roleId) {
		this.roleId = roleId;
	}

	public String getRoleName() {
		return roleName;
	}

	public void setRoleName(String roleName) {
		this.roleName = roleName;
	}

	public Long getUserId() {
		return userId;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getRealName() {
		return realName;
	}

	public void setRealName(String realName) {
		this.realName = realName;
	}

	public Integer getGender() {
		return gender;
	}

	public void setGender(Integer gender) {
		this.gender = gender;
	}

//	public Integer getUserType() {
//		return userType;
//	}
//
//    public void setUserType(Integer userType) {
//        this.userType = userType;
//    }

	public String getDuties() {
		return duties;
	}

	public void setDuties(String duties) {
		this.duties = duties;
	}

	public String getCustomName() {
		return customName;
	}

	public void setCustomName(String customName) {
		this.customName = customName;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}
}
